package com.example.service;

import com.example.mapper.master.OrderMapper;
import com.example.model.Order;
import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Objects;

/**
 * @author long
 * @date 2024/12/11 14:46
 */
@Slf4j
@Service
//@RocketMQMessageListener(topic = "order-create",consumerGroup = "order-consumer-group")
public class OrderMessageListener /*implements RocketMQListener<String>*/ {

    @Resource
    private OrderMapper orderMapper;

//    @Override
//    public void onMessage(String orderId) {
//
//        Date curDate = new Date();
//        log.info("接收消息时间：{}",curDate);
//
//        Order order = orderMapper.selectById(orderId);
//        if(Objects.isNull(order)){
//            return;
//        }
//
//        // 截止时间 < 当前时间 并且 订单没有支付
//        if(order.getDeadline().before(new Date()) && !Objects.equals(1,order.getPay())){
//            // 订单置为失效
//            order.setValid(0);
//            orderMapper.updateById(order);
//            log.info("订单:{}已经置为失效",orderId);
//        }
//    }

}
